//index.js
//获取应用实例
var app = getApp()
Page({
	data: {
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		action:'coupon/hexiao',
		pagetitle:'优惠券核销',
		
	},
	onReady: function (){
		//获得粉丝消息弹窗(需要时开启)
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (opt){
		var page=this;
		wx.setNavigationBarTitle({'title':page.data.pagetitle});
		var route=page.route;
		page.setData({
			route:route,
		});
		if(opt && opt.isgoshare){
			page.setData({
				ShowGoshare:true,
			});
		}
		console.log('opt');console.log(opt);
		if(route){
			var path=route.slice(0,-6).split('/');
			app.access.plugin=path.shift();
			app.access.action=path.join('.');
		}
		if(opt){
			opt=app.util.upopt(opt);
			app.access.query =app.util.made_query(opt,true);
			app.access.op=opt.op?opt.op:'';
		}
	},
	onShow: function (){
		var the=this;
		setTimeout(()=>{
			app.util.get(app.access,function(pagedata){
				//console.log('pagedata');console.log(pagedata);
				the.setData({
					pagedata:pagedata,
					action:app.access.action
				});
			});
		},100);
	},
	info_login:function(e){
		//根据openid为用户登陆，此处尝试获取用户信息
		app.util.getUserInfo(e);
		this.setData({
			ShowAuthM:false
		})
	},
	post:function(){
		var pagedata=this.data.pagedata
		app.util.post('jy_weishop/coupon.hexiao/post',pagedata.post);
	},
  	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		app.util[data.func](data.params);
	},
	formSubmit:function(event){
		var data=event.detail.value;
		app.util.post('jy_weishop/coupon.hexiao/post',data);
	}
});